/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import Utility.Conversion;
import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.CascadeType;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class CalendarEvent implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long eventId;
    private String eventName;
    private Date eventDate;
    private int yearlyInd;
    private Timestamp  createdDate;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    
    public void create(String name,java.util.Date eventD,boolean ind,SystemUser user)
    {
        this.setEventName(name);
        this.setEventDate(Date.valueOf(eventD.toString()));
        this.setYearlyInd(Conversion.booleanToInt(ind));
        this.setCreatedBy(user);
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
    }

    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public Date getEventDate() {
        return eventDate;
    }

    public void setEventDate(Date eventDate) {
        this.eventDate = eventDate;
    }

    public Long getEventId() {
        return eventId;
    }

    public void setEventId(Long eventId) {
        this.eventId = eventId;
    }

    public String getEventName() {
        return eventName;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    public int getYearlyInd() {
        return yearlyInd;
    }

    public void setYearlyInd(int yearlyInd) {
        this.yearlyInd = yearlyInd;
    }
    
    

    
}
